package net.cyndeline.subcut

import com.escalatesoft.subcut.inject.NewBindingModule
import com.escalatesoft.subcut.inject.bindingIdToString
import BindingKeys._
import net.cyndeline.GUI.GraphicsBuffer
import net.cyndeline.GUI.MapModifier
import net.cyndeline.GUI.PlayerEngineContainer
import net.cyndeline.GUI.input.PlayerEntityContainer
import net.cyndeline.GUI.PlayerGUIContainer
import net.cyndeline.GameMap.LevelMap
import net.cyndeline.GameMap.dataStructure.GridBasedMap
import net.cyndeline.GameMap.dataStructure.NullMap
import net.cyndeline.entitySystem.EntityManager
import net.cyndeline.entitySystem.EventSystem
import net.cyndeline.entitySystem.IdManager
import net.cyndeline.entitySystem.defaultImpl.DefaultEntityManager
import net.cyndeline.entitySystem.defaultImpl.DefaultEventSystem
import net.cyndeline.entitySystem.defaultImpl.DefaultIdManager
import net.cyndeline.entitySystem.event.AddComponent
import net.cyndeline.entitySystem.event.AddComponentEvent
import net.cyndeline.entitySystem.event.ChangedComponent
import net.cyndeline.entitySystem.event.ChangedComponentEvent
import net.cyndeline.entitySystem.event.RemovedComponent
import net.cyndeline.entitySystem.event.RemovedComponentEvent
import net.cyndeline.game.TurnHandler
import net.cyndeline.game.defaultImpl.TurnQueueHandler
import net.cyndeline.GUI.graphics.GFXBuffer
import net.cyndeline.GUI.graphics.GraphicsModifier
import net.cyndeline.game.EventProcessor
import net.cyndeline.game.defaultImpl.EventProcessorImpl
import net.cyndeline.GUI.PaintManager
import net.cyndeline.GUI.graphics.GraphicsPainter

/**
 * Dependency injection bindings.
 */
object ProjectConfiguration extends NewBindingModule(module => {
      import module._ 
      import BindingKeys._
      
      bind [String] idBy DefaultItemName toProvider			{ "<NAME_PLACEHOLDER>" }
      
      /* General */
      bind [EntityManager] toModuleSingle 					{ implicit module => new DefaultEntityManager }
      bind [IdManager] toSingle 							{ new DefaultIdManager }
      bind [LevelMap] toProvider 							{ implicit module => new GridBasedMap() }
      bind [PlayerEngineContainer] toModuleSingle 			{ implicit module => PlayerEntityContainer.make }
      bind [PlayerGUIContainer] toModuleSingle 				{ implicit module => PlayerEntityContainer.make }
      
      /* Game setup. */
      bind[GraphicsBuffer] toModuleSingle { implicit module => new GFXBuffer() }
      bind[EventSystem] toSingle { new DefaultEventSystem() }
      bind[EntityManager] toModuleSingle { implicit module => new DefaultEntityManager() }
      bind[TurnHandler] toSingle { new TurnQueueHandler() }
      bind[MapModifier] toModuleSingle { implicit module => new GraphicsModifier() }
      bind[EventProcessor] toSingle { new EventProcessorImpl() }
      bind[PaintManager] toSingle { new GraphicsPainter() }
      
      /* Config events */
      bind[AddComponentEvent] toProvider { new AddComponent() }
      bind[ChangedComponentEvent] toProvider { new ChangedComponent() }
      bind[RemovedComponentEvent] toProvider { new RemovedComponent() }
      
      })